/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * mainWin.java
 *
 * Created on 2011-05-17, 14:28:35
 */

package wdec;

import algorytm.Algorytm;
import algorytm.ZbiorRozwiazan;
import java.awt.Color;
import java.awt.Graphics2D;
import java.util.LinkedList;
import util.*;
/**
 *
 * @author cypek
 */
public class mainWin extends javax.swing.JFrame implements Runnable {

    public static int NR_ETAPU = 0;
    /** Creates new form mainWin */
    public mainWin() {
        initComponents();
        myInit();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        labMaxCredyt = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        labAmortyzacja = new javax.swing.JTextField();
        labMaxGotowki = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        labStawkaPodatku = new javax.swing.JTextField();
        labOprKredytu = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        labOprKonta = new javax.swing.JTextField();
        labKoszStaly = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        labMaxZdolnoscPro = new javax.swing.JTextField();
        labOdsprzedaz = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jLabel13 = new javax.swing.JLabel();
        sliderProd = new javax.swing.JSlider();
        jLabel14 = new javax.swing.JLabel();
        labQuantity = new javax.swing.JLabel();
        labProd = new javax.swing.JLabel();
        sliderQuality = new javax.swing.JSlider();
        sliderCredit = new javax.swing.JSlider();
        jLabel18 = new javax.swing.JLabel();
        labCredit = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        labCenaPoj = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        labInternet = new javax.swing.JTextField();
        labMagazyn = new javax.swing.JTextField();
        labTelewizja = new javax.swing.JTextField();
        sliderRyzyko = new javax.swing.JSlider();
        jLabel15 = new javax.swing.JLabel();
        labRyzyko = new javax.swing.JLabel();
        labNumerEtapussss = new javax.swing.JLabel();
        labNumerEtapu = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        gGraph = new javax.swing.JPanel();
        jSlider1 = new javax.swing.JSlider();
        jButton3 = new javax.swing.JButton();
        jLabel16 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("Majatek trawały firmy");

        jTextField1.setText("1000000");

        labMaxCredyt.setText("800000");

        jLabel2.setText("Maksymalny kredyt");

        labAmortyzacja.setText("10000");

        labMaxGotowki.setText("300000");

        jLabel3.setText("Ilosc gotówki");

        jLabel4.setText("Amortyzacja");

        jLabel5.setText("Stawka podatku");

        labStawkaPodatku.setText("0.19");

        labOprKredytu.setText("0.12");

        jLabel6.setText("Oprocentowanie kredytu");

        jLabel7.setText("Oprocentowanie konota bankowego");

        labOprKonta.setText("0.06");

        labKoszStaly.setText("10000");

        jLabel8.setText("Koszty stałe zwykłego");

        jLabel11.setText("Maksymalna zdolność produkcyjna");

        labMaxZdolnoscPro.setText("400000");

        labOdsprzedaz.setText("0.5");

        jLabel12.setText("Niesprzedane produkty skupowane za");

        jButton2.setText("Zatwierdz dane wejsciowe");

        jLabel10.setText("Ustawienia domysle juz sa w programie");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 295, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(labMaxCredyt, javax.swing.GroupLayout.PREFERRED_SIZE, 295, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(labMaxGotowki, javax.swing.GroupLayout.PREFERRED_SIZE, 295, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(labAmortyzacja, javax.swing.GroupLayout.PREFERRED_SIZE, 295, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(labKoszStaly, javax.swing.GroupLayout.PREFERRED_SIZE, 295, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(labOprKonta, javax.swing.GroupLayout.PREFERRED_SIZE, 295, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(labOprKredytu, javax.swing.GroupLayout.PREFERRED_SIZE, 295, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(labStawkaPodatku, javax.swing.GroupLayout.PREFERRED_SIZE, 295, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(labOdsprzedaz, javax.swing.GroupLayout.PREFERRED_SIZE, 295, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(labMaxZdolnoscPro, javax.swing.GroupLayout.PREFERRED_SIZE, 295, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jButton2)
                    .addComponent(jLabel10))
                .addContainerGap(371, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(labMaxCredyt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(labMaxGotowki, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(labAmortyzacja, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(labKoszStaly, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(labOprKonta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(labOprKredytu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(labStawkaPodatku, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(labOdsprzedaz, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(labMaxZdolnoscPro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jButton2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel10)
                .addContainerGap(184, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Dane Wejsciowe", jPanel1);

        jPanel2.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                ruchMyszki(evt);
            }
        });

        jLabel13.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel13.setText("Wolumen");

        sliderProd.setMaximum(400000);
        sliderProd.setPaintTicks(true);
        sliderProd.setSnapToTicks(true);
        sliderProd.setValue(0);
        sliderProd.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                sliderProdMouseClicked(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                sliderProdMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                sliderProdMouseReleased(evt);
            }
        });
        sliderProd.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                sliderProdMouseDragged(evt);
            }
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                sliderProdMouseMoved(evt);
            }
        });

        jLabel14.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel14.setText("Jakość");

        labQuantity.setText("100");

        labProd.setText("0");

        sliderQuality.setMinorTickSpacing(5);
        sliderQuality.setPaintLabels(true);
        sliderQuality.setPaintTicks(true);
        sliderQuality.setValue(100);
        sliderQuality.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                sliderQualityMouseClicked(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                sliderQualityMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                sliderQualityMouseReleased(evt);
            }
        });
        sliderQuality.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                sliderQualityMouseDragged(evt);
            }
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                sliderQualityMouseMoved(evt);
            }
        });

        sliderCredit.setMaximum(800000);
        sliderCredit.setPaintTicks(true);
        sliderCredit.setSnapToTicks(true);
        sliderCredit.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                sliderCreditMouseClicked(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                sliderCreditMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                sliderCreditMouseReleased(evt);
            }
        });
        sliderCredit.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                sliderCreditMouseDragged(evt);
            }
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                sliderCreditMouseMoved(evt);
            }
        });

        jLabel18.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel18.setText("Kredyt");

        labCredit.setText("0");

        jLabel20.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel20.setText("Jednostkowy koszt zmienny");

        labCenaPoj.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        labCenaPoj.setText("12,99");

        jLabel9.setText("Internet");

        jLabel17.setText("Magazyn");

        jLabel21.setText("Telewizja");

        jLabel22.setText("Reklama");

        labInternet.setText("0");

        labMagazyn.setText("0");

        labTelewizja.setText("0");

        sliderRyzyko.setMajorTickSpacing(10);
        sliderRyzyko.setMinorTickSpacing(5);
        sliderRyzyko.setPaintLabels(true);
        sliderRyzyko.setPaintTicks(true);
        sliderRyzyko.setValue(100);
        sliderRyzyko.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                sliderRyzykoMouseClicked(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                sliderRyzykoMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                sliderRyzykoMouseReleased(evt);
            }
        });
        sliderRyzyko.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                sliderRyzykoMouseDragged(evt);
            }
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                sliderRyzykoMouseMoved(evt);
            }
        });

        jLabel15.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel15.setText("Ryzyko");

        labRyzyko.setText("50");

        labNumerEtapussss.setText("Nr etapu");

        labNumerEtapu.setText("0");

        jButton1.setText("Koniec Tury");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout gGraphLayout = new javax.swing.GroupLayout(gGraph);
        gGraph.setLayout(gGraphLayout);
        gGraphLayout.setHorizontalGroup(
            gGraphLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 415, Short.MAX_VALUE)
        );
        gGraphLayout.setVerticalGroup(
            gGraphLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 387, Short.MAX_VALUE)
        );

        jSlider1.setOrientation(javax.swing.JSlider.VERTICAL);

        jButton3.setText("Draw");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jLabel16.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel16.setForeground(new java.awt.Color(0, 102, 255));
        jLabel16.setText("16,00");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(labCenaPoj, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel16, javax.swing.GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addGap(29, 29, 29)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jButton3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(sliderRyzyko, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                                        .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(labRyzyko, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
                                .addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(gGraph, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
                .addGap(56, 56, 56)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(labMagazyn, javax.swing.GroupLayout.PREFERRED_SIZE, 337, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labInternet, javax.swing.GroupLayout.PREFERRED_SIZE, 337, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel22)
                    .addComponent(jLabel9)
                    .addComponent(jLabel17)
                    .addComponent(jLabel21)
                    .addComponent(sliderProd, javax.swing.GroupLayout.DEFAULT_SIZE, 399, Short.MAX_VALUE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(labProd, javax.swing.GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(labQuantity, javax.swing.GroupLayout.DEFAULT_SIZE, 234, Short.MAX_VALUE))
                    .addComponent(sliderQuality, javax.swing.GroupLayout.DEFAULT_SIZE, 399, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel18, javax.swing.GroupLayout.DEFAULT_SIZE, 76, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(labCredit, javax.swing.GroupLayout.PREFERRED_SIZE, 317, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(sliderCredit, javax.swing.GroupLayout.DEFAULT_SIZE, 399, Short.MAX_VALUE)
                    .addComponent(labTelewizja, javax.swing.GroupLayout.PREFERRED_SIZE, 337, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(labNumerEtapussss, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(labNumerEtapu, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 129, Short.MAX_VALUE)
                        .addComponent(jButton1)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel20)
                            .addComponent(labCenaPoj)
                            .addComponent(jLabel16))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jSlider1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(gGraph, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(labRyzyko)
                            .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel13)
                            .addComponent(labProd, javax.swing.GroupLayout.PREFERRED_SIZE, 9, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(sliderProd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(22, 22, 22)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel14)
                            .addComponent(labQuantity))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(sliderQuality, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(23, 23, 23)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel18)
                            .addComponent(labCredit))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(sliderCredit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel22)
                        .addGap(26, 26, 26)
                        .addComponent(jLabel9)
                        .addGap(9, 9, 9)
                        .addComponent(labInternet, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel17)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(labMagazyn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(16, 16, 16)
                        .addComponent(jLabel21)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(labTelewizja, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(31, 31, 31)))
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(sliderRyzyko, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(labNumerEtapussss)
                        .addComponent(labNumerEtapu)
                        .addComponent(jButton1))
                    .addComponent(jButton3))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Decyzje", jPanel2);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 952, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 538, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void sliderProdMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sliderProdMouseClicked
        // TODO add your handling code here:

}//GEN-LAST:event_sliderProdMouseClicked

    private void sliderProdMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sliderProdMousePressed
        // TODO add your handling code here:

}//GEN-LAST:event_sliderProdMousePressed

    private void sliderProdMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sliderProdMouseReleased
        this.refreshWolumen();
}//GEN-LAST:event_sliderProdMouseReleased

    private void sliderProdMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sliderProdMouseDragged
 
}//GEN-LAST:event_sliderProdMouseDragged

    private void sliderProdMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sliderProdMouseMoved

    }//GEN-LAST:event_sliderProdMouseMoved

    private void sliderQualityMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sliderQualityMouseClicked

}//GEN-LAST:event_sliderQualityMouseClicked

    private void sliderQualityMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sliderQualityMousePressed

}//GEN-LAST:event_sliderQualityMousePressed

    private void sliderQualityMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sliderQualityMouseReleased

}//GEN-LAST:event_sliderQualityMouseReleased

    private void sliderQualityMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sliderQualityMouseDragged
 
}//GEN-LAST:event_sliderQualityMouseDragged

    private void sliderQualityMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sliderQualityMouseMoved

}//GEN-LAST:event_sliderQualityMouseMoved

    private void sliderCreditMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sliderCreditMouseClicked
 
}//GEN-LAST:event_sliderCreditMouseClicked

    private void sliderCreditMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sliderCreditMousePressed

}//GEN-LAST:event_sliderCreditMousePressed

    private void sliderCreditMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sliderCreditMouseReleased

}//GEN-LAST:event_sliderCreditMouseReleased

    private void sliderCreditMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sliderCreditMouseDragged

}//GEN-LAST:event_sliderCreditMouseDragged

    private void sliderCreditMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sliderCreditMouseMoved

}//GEN-LAST:event_sliderCreditMouseMoved

    private void sliderRyzykoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sliderRyzykoMouseClicked

    }//GEN-LAST:event_sliderRyzykoMouseClicked

    private void sliderRyzykoMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sliderRyzykoMousePressed
 

    }//GEN-LAST:event_sliderRyzykoMousePressed

    private void sliderRyzykoMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sliderRyzykoMouseReleased
        resfreshRyzyko();
        //refreshGraph();
    }//GEN-LAST:event_sliderRyzykoMouseReleased

    private void sliderRyzykoMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sliderRyzykoMouseDragged

    }//GEN-LAST:event_sliderRyzykoMouseDragged

    private void sliderRyzykoMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sliderRyzykoMouseMoved

    }//GEN-LAST:event_sliderRyzykoMouseMoved

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:

        // WAZNY PRZYCISK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1111111111111111111111111
        // WAZNY PRZYCISK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1111111111111111111111111
        // WAZNY PRZYCISK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1111111111111111111111111
        // WAZNY PRZYCISK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1111111111111111111111111
        // WAZNY PRZYCISK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1111111111111111111111111
        

          //TODO CHANGE TO EVENTS -- czyli zmiana jednej rzeczy na raz !
            //setMyPointValuesFromForm();
            
            
            algorytm.zakonczEtap();
            setMyFormValuesFromPoint(algorytm.getCurrentData());
            sliderCredit.setEnabled(false);
            resfreshRyzyko();

        if(NR_ETAPU <= 4) NR_ETAPU++;
        refreshText();
        System.out.println("-------------------------------------------------------------");
        //setMyPointValuesFromForm();

    }//GEN-LAST:event_jButton1ActionPerformed

    private void ruchMyszki(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ruchMyszki
        // TODO add your handling code here:
    }//GEN-LAST:event_ruchMyszki

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:

        refreshGraph();
    }//GEN-LAST:event_jButton3ActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        mainWin okno = new mainWin();
        okno.setVisible(true);

        new Thread(okno).start();


    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel gGraph;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JSlider jSlider1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField labAmortyzacja;
    private javax.swing.JLabel labCenaPoj;
    private javax.swing.JLabel labCredit;
    private javax.swing.JTextField labInternet;
    private javax.swing.JTextField labKoszStaly;
    private javax.swing.JTextField labMagazyn;
    private javax.swing.JTextField labMaxCredyt;
    private javax.swing.JTextField labMaxGotowki;
    private javax.swing.JTextField labMaxZdolnoscPro;
    private javax.swing.JLabel labNumerEtapu;
    private javax.swing.JLabel labNumerEtapussss;
    private javax.swing.JTextField labOdsprzedaz;
    private javax.swing.JTextField labOprKonta;
    private javax.swing.JTextField labOprKredytu;
    private javax.swing.JLabel labProd;
    private javax.swing.JLabel labQuantity;
    private javax.swing.JLabel labRyzyko;
    private javax.swing.JTextField labStawkaPodatku;
    private javax.swing.JTextField labTelewizja;
    private javax.swing.JSlider sliderCredit;
    private javax.swing.JSlider sliderProd;
    private javax.swing.JSlider sliderQuality;
    private javax.swing.JSlider sliderRyzyko;
    // End of variables declaration//GEN-END:variables
    private LinkedList<MyPoint> pListToDraw;
    private MyPoint presentPoint;
    LagrInterpolation lagrInter = new LagrInterpolation(0, 0); // pusty konstrutkor ;
   // Ryzyko solver;
    Algorytm algorytm;
    ZbiorRozwiazan zbior;

    private void myInit() {



        setProgramConst();



        presentPoint = new MyPoint(0,0,0,0,0,0);
        //solver = new Ryzyko(presentPoint);
        algorytm = new Algorytm(presentPoint);
        zbior = new ZbiorRozwiazan(100);
        zbior.PoliczZbiorRozwiazan();
        this.sliderCredit.setValue((int)(ProgramConst.maxKredyt * (this.sliderRyzyko.getValue() * 0.01)));
        presentPoint.setWzietyKredyt(sliderCredit.getValue());
        algorytm.calculate(presentPoint, Algorytm.ZmianaKredytu);
        System.out.println("SETUP\tFINISHED\tOK");

    }

    private void refreshText() {

        

        this.jLabel16.setText(String.valueOf(presentPoint.getCenaJedSprzedaz()));
        this.labCenaPoj.setText(String.valueOf(presentPoint.getCenaJed()));
        this.labCredit.setText(String.valueOf(this.sliderCredit.getValue()));
        this.labProd.setText(String.valueOf(this.sliderProd.getValue()));
        this.labQuantity.setText(String.valueOf(this.sliderQuality.getValue()));
        this.labRyzyko.setText(String.valueOf(this.sliderRyzyko.getValue()));
        this.labNumerEtapu.setText(String.valueOf(NR_ETAPU));


        //setMyFormValuesFromPoint(presentPoint);
            

    }

    private void setProgramConst()
    {
        ProgramConst.amortyzacja = Integer.parseInt(this.labAmortyzacja.getText());
        ProgramConst.iloscGotowki = Integer.parseInt(this.labMaxGotowki.getText());
        ProgramConst.kosztyStale = Integer.parseInt(this.labKoszStaly.getText());
        ProgramConst.maxKredyt = Integer.parseInt(this.labMaxCredyt.getText());
        ProgramConst.oprocentowanieKontaBankowego = Double.parseDouble(this.labOprKonta.getText());
        ProgramConst.oprocentowanieKredytu = Double.parseDouble(this.labOprKredytu.getText());
        ProgramConst.skupowaneZa = Double.parseDouble(this.labOdsprzedaz.getText());
        ProgramConst.stawkaPodaktu = Double.parseDouble(this.labStawkaPodatku.getText());
        ProgramConst.zdlonoscProdukcyjna = Integer.parseInt(this.labMaxZdolnoscPro.getText());
    }

    private void setMyPointValuesFromForm()
    {
        presentPoint.setWolumen(this.sliderProd.getValue());
        presentPoint.setJakosc(sliderQuality.getValue());
        presentPoint.setCenaJed(lagrInter.getKosztJed(presentPoint.getWolumen(), presentPoint.getJakosc()));




        presentPoint.setReklamaInet(Double.parseDouble(this.labInternet.getText()));
        presentPoint.setReklamaTV(Double.parseDouble(this.labTelewizja.getText()));
        presentPoint.setReklamaMag(Double.parseDouble(this.labMagazyn.getText()));
        presentPoint.setRyzyko(this.sliderRyzyko.getValue());  
    }

    private void setMyFormValuesFromPoint(MyPoint point)
    {
        this.sliderProd.setValue(point.getWolumen());
        this.sliderQuality.setValue(point.getJakosc());
        this.labInternet.setText(String.valueOf(point.getReklamaInet()));
        this.labMagazyn.setText(String.valueOf(point.getReklamaMag()));
        this.labTelewizja.setText(String.valueOf(point.getReklamaTV()));

        this.sliderCredit.setValue((int)point.getWzietyKredyt());
        

    }


    private void refreshWolumen(){
        presentPoint.setWolumen(sliderProd.getValue());
        presentPoint.setCenaJed(lagrInter.getKosztJed(presentPoint.getWolumen(), presentPoint.getJakosc())); //debug
        algorytm.calculate(presentPoint, Algorytm.ZmianaWolumenu); //debug
        setMyFormValuesFromPoint(algorytm.getCurrentData());
    }

    private void resfreshRyzyko() {
        setMyPointValuesFromForm();
        presentPoint.setRyzyko(sliderRyzyko.getValue()/100.0);
        //System.out.println("\t% Nowy poziom ryzyka - " + presentPoint.getRyzyko() + " %");
        algorytm.calculate(presentPoint, Algorytm.ZmianaRYZYKA);
        setMyFormValuesFromPoint(algorytm.getCurrentData());
    }

      public void refreshGraph() {

        Graphics2D g = (Graphics2D)gGraph.getGraphics();
        int offset = 20;
        int przedzialka = 10;

        int w = gGraph.getWidth();
        int h = gGraph.getHeight();

        int startX = offset;
        int startY = h - offset;

        int wartosciY = (int)(Math.log10(zbior.getValueList().getLast()/ przedzialka));
        g.setColor(Color.white);
        g.fillRect(0,0,w,h);

        g.setColor(Color.black);
        g.drawLine(startX, startY, startX, 0); // linia pinowa
        g.drawLine(startX, startY, w, startY);

        int dlugoscLiniX = w - startX;
        int dlugoscLiniY = h - offset;

        int skokX = (int)(dlugoscLiniX / przedzialka);
        int skokY = (int)(dlugoscLiniY / przedzialka);
        int skokP = (int)(dlugoscLiniX / zbior.getValueList().size());

        for(int i = 0; i <= przedzialka; i++)
        {
            g.drawLine(startX + skokX*i , startY-2, startX + skokX*i, startY+2); // przedzialka X
            g.drawString(Integer.toString(i*10), startX + skokX*i , h); // liczby na dole

            g.drawLine( offset - 2 , startY - skokY*i, offset + 2, startY - skokY*i); // przedzialka X
            if(i!=0) g.drawString(Integer.toString(i*wartosciY), 0 , h - skokY*(i)); // liczby na dole

        }
        double skala = zbior.getValueList().getLast() / h;
        for(int i = 0; i < zbior.getValueList().size(); i++)
        {

            g.fillRect(offset + (int)(i*skokP), (int)(h - skala*Math.log10(zbior.getValueList().get(i))), 2, 2);
            if(this.sliderRyzyko.getValue() == i) {
                g.setColor(Color.red);
                g.fillRect(offset + (int)(i*skokP), (int)(h - skala*Math.log10(zbior.getValueList().get(i))), 4, 4);
                g.drawString(Integer.toString(NR_ETAPU),offset + (int)(i*skokP), (int)(h - 5 - skala*Math.log10(zbior.getValueList().get(i))));
                g.setColor(Color.black);
            }

        }

    }

    public void run() {
        resfreshRyzyko();
        while(true)
        {
            try{

                //refreshGraph();
                refreshText();
                
                Thread.sleep(50);
            }
            catch(Exception ex)
            {
            }
        }

    }


}






/*
 *
 *
 *  zmiana RYZYKA -> zmienia KREDYT (+?reklame?), a co samo w sobie zmienia wolumen do sprzedazy -> rosnie zysk.
    zmiana ZYSKU -> zmienia cene, jakosc, ?reklame?

    zmiana WOLUMENU zmienia ZYSK
    zmiana CENY zmienia ZYSK
    zmiana JAKOSCI zmienia ZYSK

    te 3 powyzsze zmieniaja w stopniu DUZYM ZYSK, a w MALYM (logarytmicznie) zmieniaja RYZYKO

 *
 *
 *
 *
 *
 */